home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 …ember: Reference Library / Dev.CD Dec 98 RL1.toast / Technical Documentation / develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / UTwistDownGlobals.cp < prev    next >
Encoding:
Text File  |  1996-09-23  |  4.2 KB  |  165 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UTwistDownGlobals.cp
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1994-1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7.  
  8. #ifndef __UTWISTDOWNGLOBALS__
  9. #include "UTwistDownGlobals.h"
  10. #endif
  11.  
  12. //MacApp stuff
  13.  
  14. //Needed for gObjectHeap
  15. #ifndef __UMEMORY__
  16. #include "UMemory.h"
  17. #endif
  18.  
  19. //ObjectHeap.h required for 68k
  20. #ifndef __OBJECTHEAP__
  21. #include "ObjectHeap.h"
  22. #endif
  23.  
  24. //Needed for gSizeHeapIncrement
  25. #ifndef __UNIVERSALSTARTUP__
  26. #include "UniversalStartup.h"
  27. #endif
  28.  
  29. //Needed for gOHRemainingIncrements
  30. #ifndef PLATFORMMEMORY_H
  31. #include "PlatformMemory.h"
  32. #endif
  33.  
  34. //ToolBox stuff
  35. #ifndef __STANDARDFILE__
  36. #include "StandardFile.h"
  37. #endif
  38.  
  39. #ifndef __FILES__
  40. #include "Files.h"
  41. #endif
  42.  
  43. //ANSI stuff
  44. //None
  45. //----------------------------------------------------------------------------------------
  46. // Globals
  47. //----------------------------------------------------------------------------------------
  48.  
  49. FileFilterYDProcPtr gFileFilterYDProcPtr = MyCustomFileFilter;
  50. DlgHookYDProcPtr gDlgHookYDProcPtr = MyCustomDlgHook;
  51.  
  52. //In a normal application the following three globals would be #if qDebug
  53. Boolean gFailHere;
  54. Boolean gSendAppleEvents;
  55. Boolean gUseSystemDirection;
  56. EAppleEventRouting gAppleEventRouting;
  57. //----------------------------------------------------------------------------------------
  58. // MyCustomFileFilter: 
  59. //----------------------------------------------------------------------------------------
  60. #pragma segment MAGlobalRes
  61. pascal Boolean MyCustomFileFilter(CInfoPBPtr PB, void *yourDataPtr)
  62. {
  63. #pragma unused yourDataPtr
  64.  
  65. Boolean result;
  66.  
  67. result = TRUE;
  68.  
  69. if (((*PB).hFileInfo.ioFlAttrib & ioDirMask) == ioDirMask)    
  70.     result = FALSE;
  71.     
  72. return result;
  73. }
  74. //----------------------------------------------------------------------------------------
  75. // MyCustomDlgHook: 
  76. //----------------------------------------------------------------------------------------
  77. #pragma segment MAGlobalRes
  78. pascal short MyCustomDlgHook(short item, DialogPtr theDialog, void *yourDataPtr)
  79. {
  80. #pragma unused yourDataPtr
  81. short result;
  82. short myType;
  83. Handle myHandle;
  84. CStr255 myName;
  85. Rect myRect;
  86.  
  87. result = item;
  88.  
  89. if (GetWRefCon(WindowPtr(theDialog)) != (long)sfMainDialogRefCon)
  90.     return result;
  91.  
  92.         switch (item)
  93.             {
  94.                 case sfHookFirstCall:
  95.                     {
  96.                         myName = "Select";
  97.                         GetDialogItem(theDialog, sfItemOpenButton, &myType, &myHandle, &myRect);
  98.                         SetControlTitle(ControlHandle(myHandle), myName);
  99.                         result = sfHookGoToDesktop;
  100.                     }
  101.                     break;
  102.             
  103.                 case sfHookGoToDesktop:
  104.                     result = sfHookNullEvent;
  105.                     break;
  106.             
  107.                 case sfHookChangeSelection:
  108.                     result = sfHookGoToDesktop;
  109.                     break;
  110.             
  111.                 case sfHookGoToNextDrive:
  112.                     result = sfHookNullEvent;
  113.                     break;
  114.             
  115.                 case sfHookGoToPrevDrive:
  116.                     result = sfHookNullEvent;
  117.                     break;
  118.             
  119.                 case sfItemOpenButton:
  120.                 case sfHookOpenFolder:
  121.                     result = sfItemOpenButton;
  122.                     break;
  123.     
  124.             }    //end switch
  125.     
  126. return result;
  127. }
  128. //----------------------------------------------------------------------------------------
  129. // InitMaxObjectHeapSize: 
  130. //----------------------------------------------------------------------------------------
  131. #pragma segment MAGlobalRes
  132. short InitMaxObjectHeapSize()
  133. {
  134. long freeMem = FreeMem();
  135. Size heapSizeIncrement = gSizeHeapIncrement;
  136. short theNumber = 0;
  137.  
  138. if (freeMem > kFreeMemReserve)
  139.         theNumber = (freeMem - kFreeMemReserve)/heapSizeIncrement;
  140.  
  141. if (theNumber >= 1)
  142.     theNumber = theNumber -1;
  143. else
  144.     theNumber = 0;
  145.  
  146. return theNumber; //The number of times we'll let the object heap be expanded.
  147.  
  148. }
  149. //----------------------------------------------------------------------------------------
  150. // HaveObjectHeapSpace: 
  151. //----------------------------------------------------------------------------------------
  152. #pragma segment MAGlobalRes
  153. Boolean HaveObjectHeapSpace(long amountRequired)
  154.     {
  155.         Boolean result = FALSE;
  156.         long availableInHeap = gObjectHeap -> BytesFree();
  157.         long totalAvailable = availableInHeap + gOHRemainingIncrements*gSizeHeapIncrement;
  158.         
  159.         if (totalAvailable > amountRequired)
  160.             result = TRUE;
  161.             
  162.         return result;
  163.  
  164.     }
  165. #pragma segment Inline